package com.portico.dept.solarch

class ProjectQuality {

  Project project ;
  static belongsTo = {project : Project }

  static final ISSUE_STATUS = ["ALL","OPEN"] ;
  static final ISSUE_SUB_TYPE = ["Configured","Product", "Unknown", "Mixed"] ;
  static final ISSUE_TYPE = ["Defect","Change Request"] ;


  Date createdOn = new Date();
  String buildName ;
  String issueStatus ;
  String type = "Defect";
  String subType = "Defect";
  boolean clientReported = true ;
  long blockerCount = 0 ;
  long criticalCount = 0 ;
  long majorCount = 0 ;
  long minorCount = 0 ;
  long trivialCount = 0 ;
  String comments = "" ;
  String status = "";

    static constraints = {
      buildName blank:false
      issueStatus inList:ISSUE_STATUS
      type inList:ISSUE_TYPE
      subType inList:ISSUE_SUB_TYPE
      comments maxSize:4000
      status inList:(["Red", "Yellow", "Green"])
    }



   String toString() {
    "${project.name}-${buildName}-${type}-${issueStatus}"
  }

  static String CSV_HEADER =
  "{shortName},{project.name},{buildName},{createdOn},{type},{subType},{issueStatus},{status},{blockerCount},{criticalCount},{majorCount},{minorCount},{trivialCount}"

  
  String toCSVString() {
    "${subType}-${id},${project.name},${buildName},${createdOn},${type},${subType},${issueStatus},${status},${blockerCount},${criticalCount},${majorCount},${minorCount},${trivialCount}"
  }
}
